#include "TaskQueue.h"
template<typename T>
TaskQueue<T>::~TaskQueue()
{
	std::unique_lock<std::mutex> locker(m_mutex);
	int count = m_TaskQueue.size();
	for (int i = 0; i < count; i++)
	{
		Task<T> task = m_TaskQueue.front();
		m_TaskQueue.pop();
		delete task.arg;
	}
}
template <typename T>
void TaskQueue<T>::addTask(Task<T> task)
{
	std::unique_lock<std::mutex> locker(m_mutex);
	m_TaskQueue.push(task);
}

template <typename T>
Task<T> TaskQueue<T>::takeTask()
{
	if(m_TaskQueue.empty())
		return Task<T>();
	std::unique_lock<std::mutex> locker(m_mutex);
	Task<T> task = m_TaskQueue.front();
	m_TaskQueue.pop();
	return task;
}
